<!-- 底部结算 -->
<template>
	<view class="container" :class="{'active': !useShoppingCart.isShowDelete}" :style="{'paddingBottom': safeAreaBottom}">
		<!-- 折扣 -->
		<view class="discount">
			<image class="icon" src="/pagesC-shopping/static/images/discount.svg" mode="widthFix"></image>
			<text class="text">商品限时 <text class="red">8.5</text> 折优惠，下单立省 <text class="red">8</text> 元</text>
			<button class="close-btn iconfont btn-transition-scale9">&#xe60d;</button>
		</view>
		<!-- 结算操作 -->
		<view class="operation">
			<view class="radio-label" @click="checked = !checked">
				<text class="checkbox iconfont" :class="{'active': checked}">
					{{checked ? '&#xe62c;': '&#xe6a6;'}}
				</text>
				<text class="text">全选</text>
			</view>
			<view class="summary">
				<view class="summary-box">
					<text class="label">合计：</text>
					<text class="unit">￥</text>
					<text class="sum">39.60</text>
				</view>
				<text class="tips">免费配送</text>
			</view>
			<button class="submit-btn btn-transition-scale95" @click="handleSubmit()">去结算(3)</button>
		</view>
	</view>
</template>

<script setup>
	import { onBeforeMount, ref } from 'vue';
	import { useShoppingCartStore } from '../store.js';

	const props = defineProps({
		height: '',
		visible: false,
	});
	const emits = defineEmits('update:height');
	
	const safeAreaBottom = getApp().globalData.safeAreaBottom + 'px'; // 底部安全区域高度
	const useShoppingCart = useShoppingCartStore();
	const checked = ref(false);

	onBeforeMount(() => {
		emits('update:height', '188rpx');
	});
	
	
	const handleSubmit = () => {
		uni.navigateTo({
			url: '/pagesC-shopping/submit-order/index'
		})
	}
</script>

<style lang="scss" scoped>
	.container {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		transform: translateY(100%);
		transition: transform 0.2s;
		
		&.active {
			transform: translateY(0);
		}
	}

	.discount {
		display: flex;
		align-items: center;
		height: 56rpx;
		padding-left: 34rpx;
		background: linear-gradient(270deg, #FFEBE4 0%, #FEF3F0 20%, #FEE6E7 68%, #EEECFB 100%);

		.icon {
			width: 33rpx;
			height: 33rpx;
		}

		.text {
			flex-grow: 1;
			font-weight: 500;
			font-size: 24rpx;
			color: #222222;
			padding: 0 10rpx;

			.red {
				color: #F93023;
			}
		}

		.close-btn {
			width: 56rpx;
			height: 56rpx;
			font-size: 18rpx;
			text-align: center;
			line-height: 56rpx;
			color: #F93023;
			background-color: transparent;
		}
	}

	.operation {
		display: flex;
		align-items: center;
		height: 122rpx;
		padding: 0 38rpx 0 28rpx;

		.radio-label {
			flex-grow: 1;
			display: flex;
			align-items: center;

			.checkbox {
				flex-shrink: 0;
				font-size: 40rpx;
				color: #DCDCDC;
				margin-right: 10rpx;
			
				&.active {
					color: #FE3333;
				}
			}

			.text {
				font-weight: 500;
				font-size: 24rpx;
				color: #999999;
				margin-left: 4rpx;
			}
		}

		.summary {
			&-box {
				display: flex;
				align-items: flex-end;

				.label {
					font-weight: 500;
					font-size: 24rpx;
					color: #222222;
					line-height: 1.3;
				}

				.unit {
					font-weight: bold;
					font-size: 24rpx;
					color: #FE3333;
					line-height: 1.3;
				}

				.sum {
					font-weight: bold;
					font-size: 33rpx;
					color: #FE3333;
					line-height: 1;
				}
			}

			.tips {
				font-weight: 500;
				font-size: 24rpx;
				color: #999999;
				line-height: 1.5;
			}
		}

		.submit-btn {
			width: 198rpx;
			height: 72rpx;
			font-weight: bold;
			font-size: 30rpx;
			color: #FFFFFF;
			text-align: center;
			line-height: 72rpx;
			background: #FE3333;
			border-radius: 36rpx;
			margin-left: 28rpx;
		}
	}
</style>